Jo Shields: Enormity
(This blog post is a more firm version of a series of tweets and forum posts I made a few weeks ago. This should also be considered a refresh of this post by Mirco Bauer a few years ago)
It has been said that Mono is bloated, and that people should use lighter frameworks that don t pull in hundreds of meg .
How much basis in reality is there for those comments?
Well, let s do a little thought exercise. How much space is the minimum space needed for several languages to work?
For this experiment, we will be looking at the required installation size on disk of several language frameworks, each time installing the bare minimum for a command-line hello world app in that language to run. For example, the Ruby result is the minimum install required to run:
puts 'Hello world'and the Mono result is the minimum install required to run the following code, which has been compiled on a different machine using dmcs :
public class Hello1 public static void Main() System.Console.WriteLine("Hello, World!");Obviously, for dynamic languages like Ruby and Python, there is no compiler step needed. For languages like C# and Java, it is fair to compile these on a different machine as end-users of packages running these frameworks receive binaries, not source they do not need a development environment. So, on to the test environment. This is a bare bootstrapped AMD64 Debian Unstable system, as of today (i.e. debootstrap sid /tmp/badger ). Its install size is 275MB. So how much space? Ruby 1.9 Test code is as follows:
puts 'Hello world'Install requirements are as follows:
root@dream:/# aptitude install ruby1.9.1 The following NEW packages will be installed: libffi5 a libruby1.9.1 a libyaml-0-2 a ruby1.9.1 0 packages upgraded, 4 newly installed, 0 to remove and 0 not upgraded. Need to get 4703 kB of archives. After unpacking 13.1 MB will be used.OpenJDK 7 Test code is as follows:
class HelloWorldApp public static void main(String[] args) System.out.println("Hello world");Install requirements are as follows:
root@dream:/# aptitude install openjdk-7-jre-headless The following NEW packages will be installed: ca-certificates a ca-certificates-java a dbus a fontconfig-config a icedtea-7-jre-cacao a icedtea-7-jre-jamvm a java-common a krb5-locales a libavahi-client3 a libavahi-common-data a libavahi-common3 a libcap2 a libcups2 a libdbus-1-3 a libexpat1 a libffi5 a libfontconfig1 a libfreetype6 a libglib2.0-0 a libglib2.0-data a libgssapi-krb5-2 a libjpeg8 a libk5crypto3 a libkeyutils1 a libkrb5-3 a libkrb5support0 a liblcms2-2 a libnspr4 a libnss3 libnss3-1d a libpcre3 a libpcsclite1 a libsystemd-login0 a libxml2 a openjdk-7-jre-headless openjdk-7-jre-lib a openssl a sgml-base a shared-mime-info a ttf-dejavu-core a tzdata-java a ucf a xml-core a 0 packages upgraded, 43 newly installed, 0 to remove and 0 not upgraded. Need to get 51.5 MB of archives. After unpacking 137 MB will be used.Python 3.2 Test code is as follows:
print ("Hello world")Install requirements are as follows:
root@dream:/# aptitude install python3.2-minimal The following NEW packages will be installed: file a libexpat1 a libffi5 a libmagic1 a mime-support a python3.2 a python3.2-minimal 0 packages upgraded, 7 newly installed, 0 to remove and 0 not upgraded. Need to get 4853 kB of archives. After unpacking 17.7 MB will be used.Mono 2.10 (C#) Test code is as follows:
public class Hello public static void Main() System.Console.WriteLine("Hello world");Install requirements are as follows:
root@dream:/# aptitude install mono-runtime The following NEW packages will be installed: binfmt-support a cli-common a libmono-corlib4.0-cil a libmono-i18n-west4.0-cil a libmono-i18n4.0-cil a libmono-security4.0-cil a libmono-system-configuration4.0-cil a libmono-system-security4.0-cil a libmono-system-xml4.0-cil a libmono-system4.0-cil a mono-4.0-gac a mono-gac a mono-runtime 0 packages upgraded, 13 newly installed, 0 to remove and 0 not upgraded. Need to get 4383 kB of archives. After unpacking 11.5 MB will be used.Of course, every time I try to make the argument that Mono is much leaner than what people propose as an alternative, the anti-Mono brigade go on the defensive and insist that nobody in their right minds uses Python or Ruby either everything ever should be written in Qt. So, hypothetically Qt 4.8 (C++) Test code is as follows:
#include <QTextStream> int main(int argc, char **argv) QTextStream s(stdout); s << "Hello, world!\n"; return 0;Install requirements are as follows:
root@dream:/# aptitude install libqtcore4 The following NEW packages will be installed: libffi5 a libglib2.0-0 a libglib2.0-data a libpcre3 a libqtcore4 libxml2 a sgml-base a shared-mime-info a xml-core a 0 packages upgraded, 9 newly installed, 0 to remove and 0 not upgraded. Need to get 10.3 MB of archives. After unpacking 27.8 MB will be used.Presented without comment for your consideration. Edit: There are complaints that these numbers are misleading, because they show default package manager behaviour, rather than what happens when passing extra flags or config file settings to Apt. When disabling installation of Recommends: packages, the numbers change as follows:
- openjdk-7-jre-headless 137 MB -> 116 MB
- ruby1.9.1 13.1 MB -> 13.1 MB
- python3.2-minimal 17.7 MB -> 6.1 MB
- mono-runtime 11.5 MB -> 10.9 MB
- libqtcore4 27.8 MB -> 13.7 MB